﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlatRedBall;
using FlatRedBall.Math.Geometry;
using Microsoft.Xna.Framework.Graphics;

namespace TopDownShooter
{
    class Pickup : PositionedObject
    {
        internal AxisAlignedRectangle Rectangle;
        public Pickup()
        {
            Rectangle = ShapeManager.AddAxisAlignedRectangle();
            Rectangle.AttachTo(this, false);
        }
        public virtual void PickedUpBy(Unit whoPickedUp)
        {
            Destroy();
        }

        internal void Destroy()
        {
            ShapeManager.Remove(Rectangle);
            Rectangle.RemoveSelfFromListsBelongingTo();
            RemoveSelfFromListsBelongingTo();
        }
    }
    class Health : Pickup
    {
        public Health() : base()
        {
            Rectangle.Color = Color.Green;
        }
        public override void PickedUpBy(Unit whoPickedUp)
        {
            if (whoPickedUp.Health == 100)
                return;
            whoPickedUp.AddHealth(50);
            base.PickedUpBy(whoPickedUp);
        }
    }
    class Ammo : Pickup
    {
        public Ammo()
            : base()
        {
            Rectangle.Color = Color.LightBlue;
        }
        public override void PickedUpBy(Unit whoPickedUp)
        {
            whoPickedUp.weapon.clipCount += whoPickedUp.weapon.startingClipCount / 2;
            // Hack to make ammo update
            whoPickedUp.weapon.Activity();
            base.PickedUpBy(whoPickedUp);
        }
    }
}
